<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>文章列表--layui后台管理模板</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="format-detection" content="telephone=no">
<link rel="stylesheet" href="../../js/layui/css/layui.css" media="all" />
<script src="../../js/layui/layui.js"></script>
<link rel="stylesheet" href="../../css/font_eolqem241z66flxr.css"
	media="all" />
<link rel="stylesheet" href="../../css/news.css" media="all" />

<style type="text/css">
.layui-table-cell {
	text-align: center;
	height: auto;
	white-space: normal;
	width: auto;
}
</style>
</head>
<body class="childrenBody">
	<blockquote class="layui-elem-quote news_search">
		<form class="layui-form" method="post" onsubmit="return false;">
			<label class="layui-form-mid">设计师名:</label>
			<div class="layui-input-inline">
				<input type="text" id="name" name="name" placeholder="请输入设计师名"
					autocomplete="off" class="layui-input">
			</div>
			<div class="layui-input-inline" style="width: 100px;">
				<button class="layui-btn" id="search" data-type="reload">搜索</button>
			</div>
			<div class="layui-inline">
				<a class="layui-btn layui-btn-normal newsAdd_btn" id="newsAdd">添加设计师</a>
			</div>
		</form>

	</blockquote>
	<div class="layui-form links_list">
		<table class="layui-table" id="deigner" lay-filter="table">

		</table>
	</div>

	<!-- <div id="page"></div> -->
	<script type="text/html" id="barDemo">
			
			<a class="layui-btn layui-btn-sm" lay-event="edit" ><i class="layui-icon layui-icon-edit"></i>编辑</a>
			<a class="layui-btn layui-btn-danger layui-btn-sm" lay-event="del"><i class="layui-icon layui-icon-delete"></i>删除</a>
		</script>
	<script type="text/javascript">
		layui
				.use(
						[ 'table', 'layer' ],
						function() {
							var table = layui.table, $ = layui.$, layer = layui.layer;
							table
									.render({
										elem : '#deigner',
										width : 1005,
										url : '../../../AdminServlet?reqName=selectDesigner' //数据接口
										,
										page : true,
										cols : [ [ //表头

												{
													type : 'checkbox'
												},
												{
													field : 'dId',
													title : '编号',
													width : 130
												},
												{
													field : 'dName',
													title : '姓名',
													width : 150
												},
												{
													field : 'dGrade',
													title : '职称',
													width : 170
												},
												{
													field : 'dPicture',
													title : '照片',
													width : 200,
													templet : '<div><img src="../../../images/{{d.dPicture}}"></div>'
												}, {
													title : '操作',
													align : 'center',
													fixed : 'right',
													width : 300,
													toolbar : '#barDemo'
												}

										] ],
										id : "DesignerReload"
									});
							$("#search")
									.click(
											function() {
												table
														.reload(
																'DesignerReload',
																{
																	url : '../../../AdminServlet?reqName=selectDesigner',
																	page : {
																		curr : 1
																	//重新从第 1 页开始
																	},
																	where : {
																		name : $(
																				"#name")
																				.val()
																	}
																});
											});
							table
									.on(
											'tool(table)',
											function(obj) {
												var data = obj.data; //获得当前行数据
												var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
												var tr = obj.tr; //获得当前行 tr 的 DOM 对象（如果有的话）
												sessionStorage.setItem(
														"Designer",
														JSON.stringify(data));
												if (layEvent === 'del') { //删除
													layer
															.confirm(
																	'真的删除行么',
																	function(
																			index) {
																		obj
																				.del(); //删除对应行（tr）的DOM结构，并更新缓存
																		layer
																				.close(index);
																		$
																				.post(
																						"../../../AdminServlet?reqName=deleteDesigner",
																						{
																							id : data.dId
																						},
																						function(
																								res) {
																							if (res) {
																								layer
																										.msg(
																												'删除成功',
																												{
																													icon : 1,
																													time : 1500
																												});
																							} else {
																								layer
																										.msg(
																												'删除失败',
																												{
																													icon : 2,
																													time : 1500
																												});
																							}

																						},
																						"text")
																	});
												} else if (layEvent === 'edit') { //编辑
													var id = data.dId;

													var index = layui.layer
															.open({
																title : "编辑设计师",
																type : 2,
																content : "designerUpdate.html",
																success : function(
																		layero,
																		index) {
																	layui.layer
																			.tips(
																					'点击此处返回设计师列表',
																					' .layui-layer-close',
																					{
																						tips : 3
																					});
																},
																end : function() {
																	location
																			.reload();
																}
															})

													$(window)
															.resize(
																	function() {
																		layui.layer
																				.full(index);
																	})
													layui.layer.full(index);

												}
											});
							$("#newsAdd").click(
									function() {
										var index = layui.layer.open({
											title : "添加设计师",
											type : 2,
											content : "designerAdd.html",
											success : function(layero, index) {
												layui.layer.tips('点击此处返回设计师列表',
														' .layui-layer-close',
														{
															tips : 3
														});
											},
											end : function() {
												location.reload();
											}
										})
										//改变窗口大小时，重置弹窗的高度，防止超出可视区域（如F12调出debug的操作）
										$(window).resize(function() {
											layui.layer.full(index);
										})
										layui.layer.full(index);
									})
						})
	</script>


</body>
</html>